<?php
$menu = 3;
$title = '선생님 수업정보';
$g4_path = "../"; 
require_once ($g4_path.'common.php');
require_once ('./admin.head.php');
require_once ('./admin.lib.php');

if(!isset($_GET['mb_no'])) {
    alert('잘못된 접근입니다');
}
extract($_GET);

$sql = "SELECT count(1) from course WHERE teacher = $mb_no";
$page = isset($_GET['page'])? $_GET['page']: 1;
list($totalCount) = mysql_fetch_array(mysql_query($sql));

$count = $totalCount - ($page - 1) * 20;
$sql = "SELECT mb_no, mb_name, mb_tel, mb_hp FROM g4_member g WHERE g.mb_no = '$mb_no'";
$itemData = mysql_fetch_assoc(mysql_query($sql));
$sql = "SELECT count(1) from course_order o, course c  WHERE c.teacher = {$itemData['mb_no']} and c.no = o.course";
list($itemData['studentCount']) =  mysql_fetch_array(mysql_query($sql));
$sql = "SELECT count(1) from course WHERE teacher = {$itemData['mb_no']}";
list($itemData['courseCount']) = mysql_fetch_array(mysql_query($sql));
$sql = "SELECT w_mon+w_tue+w_wed+w_thu+w_fri+w_sat from course WHERE teacher = {$itemData['mb_no']}";
list($itemData['week']) = mysql_fetch_array(mysql_query($sql));
$itemData['month'] = $itemData['week'] * 4;
//$itemData['count'] = $count--;


$limitSQL = getLimit();
$sql ="SELECT c.no as courseno, c.name as coursename, b.name as bookname, c.code as coursecode, b.no, c.perlimit, c.starttime FROM course c, book b WHERE c.teacher = $mb_no AND c.bookcode = b.no $limitSQL";
$res = mysql_query($sql);

$data = array();
while($temp = mysql_fetch_assoc($res)) {
        $sql = "SELECT count(1) FROM course_order o, course c WHERE c.teacher = $mb_no and o.course = c.no";
        list($temp['studentCount']) = mysql_fetch_array(mysql_query($sql));
        $temp['count'] = $count--;
        $temp['starttime'] = $temp['starttime']++.'시~'.$temp['starttime'].'시';
        $data [] = $temp;
}
$pager = getPager($totalCount);

$tpl->define('basic',"teacherCourseDetail.html");
$tpl->print_('basic');
require_once ('./admin.foot.php');
